using System;

namespace CSharpPro._1028;

public class User
{
    private string _username;
    private string _password;
    public string Username
    {
        get => _username;
        set
        {
            if (string.IsNullOrWhiteSpace(value))
                throw new ArgumentException("用户名不可为空");
            if (value.Length < 3 || value.Length > 15)
                throw new ArgumentException("用户名长度必须为3-15个字符");
            _username = value;
        }
    }

    public string Password
    {
        get => _password;
        set
        {
            if (string.IsNullOrWhiteSpace(value))
                throw new ArgumentException("密码不可为空");
            if (value.Length < 6 || value.Length > 20)
                throw new ArgumentException("密码长度必须为6-20个字符");
            _password = value;
        }
    }
    public User(string username, string password)
    {
        Username = username; 
    }
}